/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.models.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrator
 */
@Entity
@Table(name = "tblRoomUser", catalog = "cungonbaiDB", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TblRoomUser.findAll", query = "SELECT t FROM TblRoomUser t"),
    @NamedQuery(name = "TblRoomUser.findByRoomUserId", query = "SELECT t FROM TblRoomUser t WHERE t.roomUserId = :roomUserId"),
    @NamedQuery(name = "TblRoomUser.findByLastJointime", query = "SELECT t FROM TblRoomUser t WHERE t.lastJointime = :lastJointime")})
public class TblRoomUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "roomUserId", nullable = false)
    private Integer roomUserId;
    @Column(name = "lastJointime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastJointime;
    @OneToMany(mappedBy = "roomUserId")
    private List<TblUserAnswer> tblUserAnswerList;
    @JoinColumn(name = "userId", referencedColumnName = "userId")
    @ManyToOne
    private TblUser userId;
    @JoinColumn(name = "roomId", referencedColumnName = "roomId")
    @ManyToOne
    private TblRoom roomId;
    @OneToMany(mappedBy = "roomUserId")
    private List<TblMessage> tblMessageList;

    public TblRoomUser() {
    }

    public TblRoomUser(Integer roomUserId) {
        this.roomUserId = roomUserId;
    }

    public Integer getRoomUserId() {
        return roomUserId;
    }

    public void setRoomUserId(Integer roomUserId) {
        this.roomUserId = roomUserId;
    }

    public Date getLastJointime() {
        return lastJointime;
    }

    public void setLastJointime(Date lastJointime) {
        this.lastJointime = lastJointime;
    }

    @XmlTransient
    public List<TblUserAnswer> getTblUserAnswerList() {
        return tblUserAnswerList;
    }

    public void setTblUserAnswerList(List<TblUserAnswer> tblUserAnswerList) {
        this.tblUserAnswerList = tblUserAnswerList;
    }

    public TblUser getUserId() {
        return userId;
    }

    public void setUserId(TblUser userId) {
        this.userId = userId;
    }

    public TblRoom getRoomId() {
        return roomId;
    }

    public void setRoomId(TblRoom roomId) {
        this.roomId = roomId;
    }

    @XmlTransient
    public List<TblMessage> getTblMessageList() {
        return tblMessageList;
    }

    public void setTblMessageList(List<TblMessage> tblMessageList) {
        this.tblMessageList = tblMessageList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (roomUserId != null ? roomUserId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblRoomUser)) {
            return false;
        }
        TblRoomUser other = (TblRoomUser) object;
        if ((this.roomUserId == null && other.roomUserId != null) || (this.roomUserId != null && !this.roomUserId.equals(other.roomUserId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.models.entities.TblRoomUser[ roomUserId=" + roomUserId + " ]";
    }
    
}
